import 'package:appflutterhomeschool/provider/provider_widget.dart';
import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/route/application.dart';
import 'package:appflutterhomeschool/route/routes.dart';
import 'package:appflutterhomeschool/ui/widgets/academic_sentiment/discount_widget.dart';
import 'package:appflutterhomeschool/ui/widgets/my_app_bar.dart';
import 'package:appflutterhomeschool/ui/widgets/widgets.dart';
import 'package:appflutterhomeschool/view_model/academic_sentiment/academic_sentiment_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';



///学情页面
class AcademicSentimetPage extends StatefulWidget {
  @override
  _AcademicSentimetPageState createState() => _AcademicSentimetPageState();
}

class _AcademicSentimetPageState extends State<AcademicSentimetPage>  with AutomaticKeepAliveClientMixin{


  @override
  // ignore: must_call_super
  Widget build(BuildContext context) {
    List list1 = [
      "高三数学模拟测试",
      "期中考前物理精讲题",
      "第三课时的英语语法"
    ];
    List list2 = [
      "高三数学分析报告",
      "期中考前物理分析报告",
      "英语分析报告"
    ];
    List list3 = [
      "数学",
      "理综",
      "英语"
    ];

    return ProviderWidget<AcademicSentimentViewModel>(
      model: AcademicSentimentViewModel(context),
      onModelReady: (value) => value.initView(),
      builder: (context, viewModel, child) {
        viewModel.myAppViewModel.academicSentimentViewModel = viewModel;
        return Scaffold(
          backgroundColor: Colors.white,
          appBar: MyAppBar(
            rightIconVisible: false,
            finishBool: true,
            title: viewModel.myAppViewModel.name ?? "未选择",
            fontWeight: FontWeight.bold,
            onTapLeft: ()=>Application()
                .navigatePushToPage(context, Routes.switchClassesPage, {}),
          ),
          body: SingleChildScrollView(
            child: Column(
              children: <Widget>[
                DiscountWidget(
                  mapScore: viewModel.scoresMap,
                  onTap: () {
                    if (!viewModel.myAppViewModel.identity) {
                      Application().navigatePushToPage(
                          context, Routes.performanceCurvePage, {});
                    }
                  },
                ),
                AcademicItemTitle(
                  title: "知识点分布",
                  visible: true,
                  onTap: () {
                    Application().navigatePushToPage(
                        context, Routes.knowledgeStatisticsPage, {});
                  },
                ),
                ShadowWidget(
                  externalPadding: EdgeInsets.fromLTRB(
                      ScreenUtil().setWidth(35),
                      0,
                      ScreenUtil().setWidth(35),
                      ScreenUtil().setWidth(35)),
                  withinPadding: EdgeInsets.fromLTRB(
                      ScreenUtil().setWidth(43),
                      ScreenUtil().setWidth(74),
                      ScreenUtil().setWidth(43),
                      ScreenUtil().setWidth(74)),
                  childWidget: GridView.builder(
                      shrinkWrap: true,
                      itemCount: list3.length,
                      physics: NeverScrollableScrollPhysics(),
                      padding: EdgeInsets.symmetric(horizontal: 16),
                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 3,
                        mainAxisSpacing: 5,
                        crossAxisSpacing: 5,
                        childAspectRatio: 1,
                      ),
                      itemBuilder: (context, index) {
                        return GradientCircularProgressRoute(student: list3[index]);
                      }),
                ),
                AcademicItemTitle(
                  title: "作业任务",
                  visible: true,
                  onTap: () {
                    Application()
                        .navigatePushToPage(context, Routes.taskPage, {});
                  },
                ),
                AcademicListView(list1),
                AcademicItemTitle(
                  title: "考试分析报告",
                  visible: true,
                  onTap: () {
                    Application().navigatePushToPage(
                        context, Routes.analysisReportPage, {});
                  },
                ),
                AcademicListView(list2),
              ],
            ),
          ),
        );
      },
    );
  }

  @override
  bool get wantKeepAlive => true;
}
